package copyengine.ui.component.scrollable.scrollPanel
{
    import copyengine.ui.component.CEUIComponent;
    import copyengine.ui.component.scrollable.element.ICEScrollableElement;
    import copyengine.ui.component.scrollable.layout.CEScrollableLayout;
    import copyengine.ui.component.scrollable.moveOperator.CEScrollableMoveOperator;

    import flash.geom.Rectangle;

    import starling.display.DisplayObject;

    public class CEScrollPanel extends CEUIComponent
    {
        private var mMoveOperator:CEScrollableMoveOperator;
        private var mScrollPanelCore:CEScrollPanelCore;
        private var mDirection:int;
        private var mViewportRe:Rectangle;
        private var mMaxMoveRe:Rectangle;

        public function CEScrollPanel(_container:DisplayObject)
        {
            super(_container);
        }

        public function get viewportRe():Rectangle {return null;}

        public function get maxMoveRe():Rectangle {return null;}

        public function get direction():int {return mDirection;}

        public function moveViewPort(_newPosX:Number, _newPosY:Number):void
        {}

        public function addElement(_element:ICEScrollableElement):void
        {
            _element.scrollPanel = this;
            mScrollPanelCore.allSubElementVector.push(_element);
        }

        public function removeElement(_element:ICEScrollableElement):void {}

        public function refresh(_isElementChangeOrInit:Boolean):void
        {
            //初始化或者Element有变化时候重新计算一下移动区域
            if (_isElementChangeOrInit) {calculateMaxMoveRe();}
            CEScrollableLayout.layoutAllElement(mScrollPanelCore.allSubElementVector, mDirection);
            mScrollPanelCore.refresh(_isElementChangeOrInit);
        }

        //========================//
        //==Private  Function
        //=========================//

        private function calculateMaxMoveRe():void
        {
            //TODO::重新计算最大移动区域以后要判断一下当前Viewport是否在移动区域里面 如果不再则修正一下视口
        }

    }
}
